<?php
  //递归获取表单页分类选项html代码
 function getCateOptionHtml($selectId=0,$cate=array()){
	static $optionStr;
	if(empty($cate)){
		$cate = getCateByPid(0);
	}
	foreach ($cate as $key => $value) {
		if(is_array($selectId)){
			if(in_array($value['id'],$selectId)){
				$optionStr = $optionStr.'<option value="'.$value['id'].'" selected="selected">';
			}else{
				$optionStr = $optionStr.'<option value="'.$value['id'].'">';
			}
		}else{
			if($selectId==$value['id']){
				$optionStr = $optionStr.'<option value="'.$value['id'].'" selected="selected">';
			}else{
				$optionStr = $optionStr.'<option value="'.$value['id'].'">';
			}
		}
		
		for ($i=1; $i <$value['level'] ; $i++) { 
			$optionStr = $optionStr.'&nbsp;&nbsp;&nbsp;';
		}
		if($value['level']==1){
			$optionStr = $optionStr.$value['name'].'</opton>';
		}else{
			$optionStr = $optionStr.'└─'.$value['name'].'</opton>';
		}
		
		if(!empty($value['child'])){
			getCateOptionHtml($selectId,$value['child']);
		}
		
	}
	return $optionStr;
}